
package ui.adapter;

import android.content.Context;
import android.view.View;

import net.ck.hzq.R;

import java.util.ArrayList;
import java.util.List;

import Bean.GetBankcardBean;
import base.BaseViewHolder;
import base.SuperBaseAdapter;


/**
 *POS查询列表适配器
 * Created by chenjian on 19/2/27
 */
public class ChangebankAdapter extends SuperBaseAdapter<GetBankcardBean.DataBean.ItemsBean> {

    List<GetBankcardBean.DataBean.ItemsBean> mData = new ArrayList<>();
    Context mContext;
    public ChangebankAdapter(Context context, List<GetBankcardBean.DataBean.ItemsBean> data) {
        super(context, data);
        mContext = context;
        mData = data;
    }

    @Override
    protected void convert(BaseViewHolder holder, final GetBankcardBean.DataBean.ItemsBean item, final int position) {
        holder.setText(R.id.bankname, item.getBank()+"("+item.getBankNo().substring(item.getBankNo().length()-4,item.getBankNo().length())+")");
        if (item.getIsChecked()) {
//            holder.getView(R.id.cb).setBackgroundResource(R.mipmap.duihao);
            holder.getView(R.id.cb).setVisibility(View.VISIBLE);
        } else {
            holder.getView(R.id.cb).setVisibility(View.GONE);
        }
        holder.setOnClickListener(R.id.total_linear, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    for (int i = 0; i < mData.size(); i++) {
                        mData.get(i).setIsChecked(false);
                    }
                    item.setIsChecked(true);
                notifyDataSetChanged();
            }
        });

    }



    @Override
    protected int getItemViewLayoutId(int position,GetBankcardBean.DataBean.ItemsBean item) {
        return R.layout.item_changebank_list;
    }

}
